package com.yalemang.photovalut.base

import android.os.Bundle
import androidx.viewbinding.ViewBinding
import com.yalemang.framework.base.BaseActivity
import com.yalemang.framework.base.BasePresenter
import com.jeremyliao.liveeventbus.LiveEventBus
import com.yalemang.photovalut.base.user.Skin

abstract class BaseSkinActivity<VB: ViewBinding, P: BasePresenter<*, *>>: BaseActivity<VB, P>() {

    protected var skin = UserManager.instance.user.skin

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        switchSkin(skin)
        //接收广播替换颜色
        LiveEventBus
            .get(Skin.KEY_SWITCH_SKIN_EVENT, Skin::class.java)
            .observe(this) {
                switchSkin(it)
            }
    }

    abstract fun switchSkin(skin: Skin)
}